from neo4j import GraphDatabase
# 配置neo4j的信息
NEO4J_CONFIG = {
	# "uri": "bolt://0.0.0.0:7687",
    "uri": "bolt://localhost:7687",
    # "uri": "bolt://0.0.0.0:7474",
	"auth": ("neo4j", "123456"),
	"encrypted": False
}

with GraphDatabase.driver(**NEO4J_CONFIG).session() as session:
     cypher = "CREATE(b:newworld) SET b.greet='你好，世界' RETURN b.greet"
     record = session.run(cypher)
     result = list(map(lambda x: x[0], record))
     print(result)

def for_affair(af, student, pen):
# def for_affair():
    af.run("CREATE (s:Student{attribute: $student_name})"
           "CREATE (e:Pen{attribute: $pen_name})"
           "MERGE (s)-[r:use]-(e)",
           student_name=student, pen_name=pen)

    # af.run("ALTER CURRENT USER SET PASSWORD FROM 'neo4j' TO '123456'")
# 

with GraphDatabase.driver(**NEO4J_CONFIG).session() as session:
    session.write_transaction(for_affair, "小明", "晨光")
    # session.write_transaction(for_affair)
